package connect4swt.gui.connect4;



import org.eclipse.swt.graphics.Point;

import com.swtdesigner.SWTResourceManager;

import connect4swt.gui.ClientWindow;
import connect4swt.gui.Piece;



/**
 * @author  Joel Cordeiro
 */
public class Connect4Piece extends Piece{
	
	/**
	 * @author  Joel Cordeiro
	 */
	public enum ImageType {
		EMPTY, GREEN, ORANGE, RED, YELLOW;
	}
	
	public Connect4Piece(ImageType imageType, int x, int y, int width, int height, Point position)
	{
		super(x, y, width, height, position);
		this.imageType = imageType;
		changeImage(imageType);
	}
	
	protected void changeImage(ImageType imageType) {
		switch(imageType) {
			case EMPTY:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/Connect4Piece/emptyPiece.png");
				break;
			case GREEN:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/Connect4Piece/greenPiece.png");
				break;
			case ORANGE:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/Connect4Piece/orangePiece.png");
				break;
			case RED:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/Connect4Piece/redPiece.png");
				break;
			case YELLOW:
				this.image = SWTResourceManager.getImage(ClientWindow.class, "/images/Connect4Piece/yellowPiece.png");
				break;
		}
	}
	
	public void setType(ImageType imageType) {
		this.imageType = imageType;
		changeImage(imageType);
	}
	
	@Override
	public boolean isEmpty() {
		return (this.imageType == ImageType.EMPTY);
	}
	
	public ImageType imageType;
}
